﻿@using Abp.Web.Mvc.Extensions
@using YoYoCMS.PhoneBook
@model Abp.Application.Services.Dto.PagedResultDto<YoYoCMS.PhoneBook.Persons.Dtos.PersonListDto>
@{
    ViewBag.ActiveMenu = "Persons.Person";
    ViewBag.Title = L("PersonHeaderInfo");
}

@section scripts{
    @Html.IncludeScript("~/Views/PersonManage/Index.js")


}
<div>
    <h1>@L("Person")</h1>
    <div class="row">
        <div class="col-md-12">
            <button data-toggle="modal" data-target="#PersonCreateModal" class="btn btn-primary pull-right">
                <i class="fa fa-plus"></i> @L("CreatePerson")</button>
            <table class="table">
                <thead>
                <tr>
                    <th>操作</th>
                    <th>@L("Name")</th>
                    <th>@L("EmailAddress")</th>
                    <th>@L("CreationTime")</th>
                    <th>操作电话簿</th>
                </tr>
                </thead>
                <tbody>
                @foreach (var person in Model.Items)
                {
                    <tr>
                        <td><a href="javascript:void()" data-toggle="modal" data-target="#PersonCreateModal" onclick="editPerson(@person.Id);">编辑</a>| <a href="javascript:void()" onclick="deletePerson(@person.Id);"> 删除</a></td>
                        <td>@person.Name </td>
                        <td>@person.EmailAddress</td>
                        <td>@person.CreationTime</td>
                        <tr>
                            <th>电话类型</th>
                            <th>电话号码</th>
                        </tr>

                        @foreach (var phone in person.Phones)
                        {
                            <tr>
                                <td>@phone.Type</td>
                                <td>@phone.Number</td>
                            </tr>
                        }
                    </tr>
                }
                </tbody>
            </table>


        </div>


    </div>


</div>


<div class="modal fade" id="PersonCreateModal" tabindex="-1" role="dialog" aria-labelledby="PersonCreateModalLabel" data-backdrop="static">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <form name="tenantCreateForm" role="form" novalidate class="form-validation">
                <div class="modal-header">
                    <h4 class="modal-title">
                        <span>@L("CreatePerson")</span>
                    </h4>
                </div>
                <div class="modal-body">


                    <div class="form-group">
                        <label>@L("Name")</label>
                        <input class="form-control" type="text" value="" name="Name" required maxlength="@PhoneBookConsts.MaxNameLength" minlength="2">
                        <input type="hidden" name="Id">

                    </div>

                    <div class="form-group">
                        <label>@L("EmailAddress")</label>
                        <input class="form-control" type="email" name="EmailAddress" required maxlength="@PhoneBookConsts.MaxEmailAddressLength" minlength="2">

                    </div>


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">@L("Cancel")</button>
                    <button type="submit" class="btn btn-primary blue">
                        <i class="fa fa-save"></i> <span>@L("Save")</span>
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>